home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume24 / rcs / part02 < prev    next >
Encoding:
Internet Message Format  |  1991-03-05  |  54.3 KB

  1. Subject:  v24i002:  RCS source control system, Part02/12
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 66e8543c ec3e98df 678fbd6e bc491950
  5.  
  6. Submitted-by: Adam Hammer <hammer@cs.purdue.edu>
  7. Posting-number: Volume 24, Issue 2
  8. Archive-name: rcs/part02
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  rcs.ms.01 src/rcskeys.c
  17. # Wrapped by rsalz@litchi.bbn.com on Thu Feb 21 14:36:54 1991
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. echo If this archive is complete, you will see the following message:
  20. echo '          "shar: End of archive 2 (of 12)."'
  21. if test -f 'rcs.ms.01' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'rcs.ms.01'\"
  23. else
  24.   echo shar: Extracting \"'rcs.ms.01'\" \(49803 characters\)
  25.   sed "s/^X//" >'rcs.ms.01' <<'END_OF_FILE'
  26. X.\" Format this file with:
  27. X.\" pic file | tbl | troff -ms
  28. X.\"
  29. X.\" \*s stands for $, and avoids problems when this file is checked in.
  30. X.ds s $
  31. X.\" PS and PE center pic diagrams. (The corresponding ms-macros may not.)
  32. X.de PS
  33. X.nr pE (\\n(.lu-\\$2u)/2u
  34. X.in +\\n(pEu
  35. X.ne \\$1u
  36. X..
  37. X.de PE
  38. X.in -\\n(pEu
  39. X..
  40. X.de D(
  41. X.DS
  42. X.nr VS 12p
  43. X.vs 12p
  44. X.I
  45. X..
  46. X.de D)
  47. X.DE
  48. X.nr VS 18p
  49. X.vs 18p
  50. X.R
  51. X..
  52. X.de Id
  53. X.ND \\$4
  54. X..
  55. X.Id $Id: rcs.ms,v 5.2 1991/01/03 10:57:28 eggert Exp $
  56. X.RP
  57. X.TL
  58. XRCS\*-A System for Version Control
  59. X.sp
  60. X.AU
  61. XWalter F. Tichy
  62. X.AI
  63. XDepartment of Computer Sciences
  64. XPurdue University
  65. XWest Lafayette, Indiana 47907
  66. X.sp
  67. X.AB
  68. XAn important problem in program development and maintenance is version control,
  69. Xi.e., the task of keeping a software system consisting of many versions and
  70. Xconfigurations well organized.
  71. XThe Revision Control System (RCS)
  72. Xis a software tool that assists with that task.
  73. XRCS manages revisions of text documents, in particular source programs,
  74. Xdocumentation, and test data.
  75. XIt automates the storing, retrieval, logging and identification of revisions,
  76. Xand it provides selection mechanisms for composing configurations.
  77. XThis paper introduces basic version control concepts and
  78. Xdiscusses the practice of version control
  79. Xusing RCS.
  80. XFor conserving space, RCS stores deltas, i.e., differences between
  81. Xsuccessive revisions.  Several delta storage methods are discussed.
  82. XUsage statistics show that RCS's delta storage method is
  83. Xspace and time efficient.
  84. XThe paper concludes with a detailed survey of version control tools.
  85. X.sp
  86. X\fBKeywords\fR: configuration management, history management,
  87. Xversion control, revisions, deltas.
  88. X.AE
  89. X.FS
  90. XAn earlier version of this paper was published in
  91. X.I "Software\*-Practice & Experience"
  92. X.B 15 ,
  93. X7 (July 1985), 637-654.
  94. X.FE
  95. X.nr VS 18p
  96. X.LP
  97. X.NH
  98. XIntroduction
  99. X.PP
  100. XVersion control is the task of keeping software
  101. Xsystems consisting of many versions and configurations well organized.
  102. XThe Revision Control System (RCS) is a set of UNIX
  103. Xcommands that assist with that task.
  104. X.PP
  105. XRCS' primary function is to manage \fIrevision groups\fR.
  106. XA revision group is a set of text documents, called \fIrevisions\fR,
  107. Xthat evolved from each other.  A new revision is
  108. Xcreated by manually editing an existing one.
  109. XRCS organizes the revisions into an ancestral tree.  The initial revision
  110. Xis the root of the tree, and the tree edges indicate
  111. Xfrom which revision a given one evolved.
  112. XBesides managing individual revision groups, RCS provides
  113. Xflexible selection functions for composing configurations.
  114. XRCS may be combined with MAKE\u1\d,
  115. Xresulting in a powerful package for version control.
  116. X.PP
  117. XRCS also offers facilities for
  118. Xmerging updates with customer modifications,
  119. Xfor distributed software development, and
  120. Xfor automatic identification.
  121. XIdentification is the `stamping'
  122. Xof revisions and configurations with unique markers.
  123. XThese markers are akin to serial numbers,
  124. Xtelling software maintainers unambiguously which configuration
  125. Xis before them.
  126. X.PP
  127. XRCS is designed for both production and experimental
  128. Xenvironments.
  129. XIn production environments,
  130. Xaccess controls detect update conflicts and prevent overlapping changes.
  131. XIn experimental environments, where strong controls are
  132. Xcounterproductive, it is possible to loosen the controls.
  133. X.PP
  134. XAlthough RCS was originally intended for programs, it is useful for any
  135. Xtext that is revised frequently and whose previous revisions must be
  136. Xpreserved.  RCS has been applied successfully to store the source
  137. Xtext for drawings, VLSI layouts, documentation, specifications,
  138. Xtest data, form letters and articles.
  139. X.PP
  140. XThis paper discusses the practice of
  141. Xversion control using RCS.
  142. XIt also introduces basic version control concepts,
  143. Xuseful for clarifying current practice and designing similar systems.
  144. XRevision groups of individual components are treated in the next three sections,
  145. Xand the extensions to configurations follow.
  146. XBecause of its size, a survey of version control tools
  147. Xappears at the end of the paper.
  148. X.NH
  149. XGetting started with RCS
  150. X.PP
  151. XSuppose a text file \fIf.c\fR is to be placed under control of RCS.
  152. XInvoking the check-in command
  153. X.D(
  154. Xci  f.c
  155. X.D)
  156. Xcreates a new revision group with the contents of
  157. X\fIf.c\fR as the initial
  158. Xrevision (numbered 1.1)
  159. Xand stores the group into the file \fIf.c,v\fR.
  160. XUnless told otherwise, the command deletes \fIf.c\fR.
  161. XIt also asks for a description of the group.
  162. XThe description should state the common purpose of all revisions in the group,
  163. Xand becomes part of the group's documentation.
  164. XAll later check-in commands will ask for a log entry,
  165. Xwhich should summarize the changes made.
  166. X(The first revision is assigned a default log message,
  167. Xwhich just records the fact that it is the initial revision.)
  168. X.PP
  169. XFiles ending in \fI,v\fR
  170. Xare called \fIRCS files\fR (\fIv\fR stands for \fIv\fRersions);
  171. Xthe others are called working files.
  172. XTo get back the working file \fIf.c\fR in the previous example,
  173. Xexecute the check-out command:
  174. X.D(
  175. Xco  f.c
  176. X.D)
  177. X.R
  178. XThis command extracts the latest revision from
  179. Xthe revision group \fIf.c,v\fR and writes
  180. Xit into \fIf.c\fR.
  181. XThe file \fIf.c\fR can now be edited and, when finished,
  182. Xchecked back in with \fIci\fR:
  183. X.D(
  184. Xci  f.c
  185. X.D)
  186. X\fICi\fR assigns number 1.2 to
  187. Xthe new revision.
  188. XIf \fIci\fR complains with the message
  189. X.D(
  190. Xci error: no lock set by <login>
  191. X.D)
  192. Xthen the system administrator has decided to configure RCS for a
  193. Xproduction environment by enabling the `strict locking feature'.
  194. XIf this feature is enabled, all RCS files are initialized
  195. Xsuch that check-in operations require a lock on the previous revision
  196. X(the one from which the current one evolved).
  197. XLocking prevents overlapping modifications if several people work on the same file.
  198. XIf locking is required, the revision should
  199. Xhave been locked during the check-out by using
  200. Xthe option \fI\-l\fR:
  201. X.D(
  202. Xco  \-l  f.c
  203. X.D)
  204. XOf course it is too late now for the check-out with locking, because
  205. X\fIf.c\fR has already been changed; checking out the file again
  206. Xwould overwrite the modifications.
  207. X(To prevent accidental overwrites, \fIco\fR senses the presence
  208. Xof a working file and asks whether the user really intended to overwrite it.
  209. XThe overwriting check-out is sometimes useful for
  210. Xbacking up to the previous revision.)
  211. XTo be able to proceed with the check-in in the present case, first execute
  212. X.D(
  213. Xrcs  \-l  f.c
  214. X.D)
  215. XThis command retroactively locks the latest revision, unless someone
  216. Xelse locked it in the meantime.  In this case, the two programmers
  217. Xinvolved have to negotiate whose
  218. Xmodifications should take precedence.
  219. X.PP
  220. XIf an RCS file is private, i.e., if only the owner of the file is expected
  221. Xto deposit revisions into it, the strict locking feature is unnecessary and
  222. Xmay be disabled.
  223. XIf strict locking is disabled,
  224. Xthe owner of the RCS file need not have a lock for check-in.
  225. XFor safety reasons, all others
  226. Xstill do.  Turning strict locking off and on is done with the commands:
  227. X.D(
  228. Xrcs  \-U  f.c       \fRand\fP         rcs  \-L  f.c
  229. X.D)
  230. XThese commands enable or disable the strict locking feature for each RCS file
  231. Xindividually.
  232. XThe system administrator only decides whether strict locking is
  233. Xenabled initially.
  234. X.PP
  235. XTo reduce the clutter in a working directory, all RCS files can be moved
  236. Xto a subdirectory with the name \fIRCS\fR.
  237. XRCS commands look first into that directory for RCS files.
  238. XAll the commands presented above work
  239. Xwith the \fIRCS\fR subdirectory without change.\(dg
  240. X.FS \(dg
  241. XPairs of RCS and working files can actually be specified in 3 ways:
  242. Xa) both are given, b) only the working file is given, c) only the
  243. XRCS file is given.
  244. XIf a pair is given, both files may have arbitrary path prefixes;
  245. XRCS commands pair them up intelligently.
  246. X.FE
  247. X.PP
  248. XIt may be undesirable that \fIci\fR deletes the working file.
  249. XFor instance, sometimes one would like to save the current revision,
  250. Xbut continue editing.
  251. XInvoking
  252. X.D(
  253. Xci  \-l  f.c
  254. X.D)
  255. Xchecks in \fIf.c\fR as usual, but performs an additional
  256. Xcheck-out with locking afterwards.  Thus, the working file does
  257. Xnot disappear after the check-in.
  258. XSimilarly, the option
  259. X\fI\-u\fR does a check-in followed by a check-out without
  260. Xlocking.  This option is useful if the file is needed for compilation after the check-in.
  261. XBoth options update the identification markers in the working file
  262. X(see below).
  263. X.PP
  264. XBesides the operations \fIci\fR and \fIco\fR, RCS provides the following
  265. Xcommands:
  266. X.sp 0
  267. X.nr VS 12p
  268. X.vs 12p
  269. X.TS
  270. Xtab(%);
  271. Xli l.
  272. Xident%extract identification markers
  273. Xrcs%change RCS file attributes
  274. Xrcsclean%remove unchanged working files (optional)
  275. Xrcsdiff%compare revisions
  276. Xrcsfreeze%record a configuration (optional)
  277. Xrcsmerge%merge revisions
  278. Xrlog%read log messages and other information in RCS files
  279. X.TE
  280. XA synopsis of these commands appears in the Appendix.
  281. X.NH 2
  282. XAutomatic Identification
  283. X.PP
  284. XRCS can stamp source and object code with special identification strings,
  285. Xsimilar to product and serial numbers.
  286. XTo obtain such identification, place the marker
  287. X.D(
  288. X\*sId\*s
  289. X.D)
  290. Xinto the text of a revision, for instance inside a comment.
  291. XThe check-out operation will replace this marker with a string of the form
  292. X.D(
  293. X\*sId:  filename  revisionnumber  date  time  author  state  locker \*s
  294. X.D)
  295. XThis string need never be touched, because \fIco\fR keeps it
  296. Xup to date automatically.
  297. XTo propagate the marker into object code, simply put
  298. Xit into a literal character string.  In C, this is done as follows:
  299. X.D(
  300. Xstatic char rcsid[] = \&"\*sId\*s\&";
  301. X.D)
  302. XThe command \fIident\fR extracts such markers from any file, in particular from
  303. Xobject code.
  304. X\fIIdent\fR helps to find out
  305. Xwhich revisions of which modules were used in a given program.
  306. XIt returns a complete and unambiguous component list,
  307. Xfrom which a copy of the program can be reconstructed.
  308. XThis facility is invaluable for program maintenance.
  309. X.PP
  310. XThere are several additional identification markers, one for each component
  311. Xof \*sId\*s.
  312. XThe marker
  313. X.D(
  314. X\*sLog\*s
  315. X.D)
  316. Xhas a similar function.  It accumulates
  317. Xthe log messages that are requested during check-in.
  318. XThus, one can maintain the complete history of a revision directly inside it,
  319. Xby enclosing it in a comment.
  320. XFigure 1 is a partial reproduction of a log contained in revision 4.1 of
  321. Xthe file \fIci.c\fR.  The log appears at the beginning of the file,
  322. Xand makes it easy to determine what the recent modifications were.
  323. X.sp
  324. X.nr VS 12p
  325. X.vs 12p
  326. X.ne 18
  327. X.nf
  328. X.in +0.5i
  329. X/* \*sLog: ci.c,v \*s
  330. X * Revision 4.1  1983/05/10  17:03:06  wft
  331. X * Added option \-d and \-w, and updated assignment of date, etc. to new delta.
  332. X * Added handling of default branches.
  333. X *
  334. X * Revision 3.9  1983/02/15  15:25:44  wft
  335. X * Added call to fastcopy() to copy remainder of RCS file.
  336. X *
  337. X * Revision 3.8  1983/01/14  15:34:05  wft
  338. X * Added ignoring of interrupts while new RCS file is renamed;
  339. X * avoids deletion of RCS files by interrupts.
  340. X *
  341. X * Revision 3.7  1982/12/10  16:09:20  wft
  342. X * Corrected checking of return code from diff.
  343. X * An RCS file now inherits its mode during the first ci from the working file,
  344. X * except that write permission is removed.
  345. X */
  346. X.in 0
  347. X.ce 1
  348. XFigure 1.  Log entries produced by the marker \*sLog\*s.
  349. X.fi
  350. X.nr VS 18p
  351. X.vs 18p
  352. X.sp 0
  353. X.LP
  354. XSince revisions are stored in the form of differences,
  355. Xeach log message is
  356. Xphysically stored once,
  357. Xindependent of the number of revisions present.
  358. XThus, the \*sLog\*s marker incurs negligible space overhead.
  359. X.NH
  360. XThe RCS Revision Tree
  361. X.PP
  362. XRCS arranges revisions in an ancestral tree.
  363. XThe \fIci\fR command builds this tree; the auxiliary command \fIrcs\fR
  364. Xprunes it.
  365. XThe tree has a root revision, normally numbered 1.1, and successive revisions
  366. Xare numbered 1.2, 1.3, etc.  The first field of a revision number
  367. Xis called the \fIrelease number\fR and the second one
  368. Xthe \fIlevel number\fR.  Unless given explicitly,
  369. Xthe \fIci\fR command assigns a new revision number
  370. Xby incrementing the level number of the previous revision.
  371. XThe release number must be incremented explicitly, using the
  372. X\fI\-r\fR option of \fIci\fR.
  373. XAssuming there are revisions 1.1, 1.2, and 1.3 in the RCS file f.c,v, the command
  374. X.D(
  375. Xci  \-r2.1  f.c       \fRor\fP       ci  \-r2  f.c
  376. X.D)
  377. Xassigns the number 2.1 to the new revision.
  378. XLater check-ins without the \fI\-r\fR option will assign the numbers 2.2, 2.3,
  379. Xand so on.
  380. XThe release number should be incremented only at major transition points
  381. Xin the development, for instance when a new release of a software product has
  382. Xbeen completed.
  383. X.NH 2
  384. XWhen are branches needed?
  385. X.PP
  386. XA young revision tree is slender:
  387. XIt consists of only one branch, called the trunk.
  388. XAs the tree ages, side branches may form.
  389. XBranches are needed in the following 4 situations.
  390. X.IP "\fITemporary fixes\fR"
  391. X.sp 0
  392. XSuppose a tree has 5 revisions grouped in 2 releases,
  393. Xas illustrated in Figure 2.
  394. XRevision 1.3, the last one of release 1, is in operation at customer sites,
  395. Xwhile release 2 is in active development.
  396. X.ne 4
  397. X.PS 4i
  398. X.ps -2
  399. Xbox "1.1"
  400. Xarrow
  401. Xbox "1.2"
  402. Xarrow
  403. Xbox "1.3"
  404. Xarrow
  405. Xbox "2.1"
  406. Xarrow
  407. Xbox "2.2"
  408. Xarrow dashed
  409. X.ps +2
  410. X.PE
  411. X.ce 1
  412. XFigure 2.  A slender revision tree.
  413. X.sp 0
  414. XNow imagine a customer requesting a fix of
  415. Xa problem in revision 1.3, although actual development has moved on
  416. Xto release 2.  RCS does not permit an extra
  417. Xrevision to be spliced in between 1.3 and 2.1, since that would not reflect
  418. Xthe actual development history.  Instead, create a branch
  419. Xat revision 1.3, and check in the fix on that branch.
  420. XThe first branch starting at 1.3 has number 1.3.1, and
  421. Xthe revisions on that branch are numbered 1.3.1.1, 1.3.1.2, etc.
  422. XThe double numbering is needed to allow for another
  423. Xbranch at 1.3, say 1.3.2.
  424. XRevisions on the second branch would be numbered
  425. X1.3.2.1, 1.3.2.2, and so on.
  426. XThe following steps create
  427. Xbranch 1.3.1 and add revision 1.3.1.1:
  428. X.sp 0
  429. X.I
  430. X.nr VS 12p
  431. X.vs 12p
  432. X.TS
  433. Xtab(%);
  434. Xl l l.
  435. X     %co  \-r1.3  f.c% \*- check out revision 1.3
  436. X     %edit  f.c% \*- change it
  437. X     %ci  \-r1.3.1  f.c% \*- check it in on branch 1.3.1
  438. X.TE
  439. X.nr VS 18p
  440. X.vs 18p
  441. X.R
  442. XThis sequence of commands transforms the tree of Figure 2 into
  443. Xthe one in Figure 3.
  444. XNote that it may be necessary to incorporate the differences
  445. Xbetween 1.3 and 1.3.1.1
  446. Xinto a revision at level 2.  The operation \fIrcsmerge\fR automates this
  447. Xprocess (see the Appendix).
  448. X.ne 7
  449. X.PS  4i
  450. X.ps -2
  451. X     box "1.1"
  452. X     arrow
  453. X     box "1.2"
  454. X     arrow
  455. XR13: box "1.3"
  456. X     arrow
  457. XR21: box "2.1"
  458. X     arrow
  459. XR22: box "2.2"
  460. X     arrow dashed
  461. X     line invis down from R21.s
  462. XRB1: box "1.3.1.1"
  463. X     arrow dashed right from RB1.e
  464. X     arrow from R13.s to RB1.w
  465. X.ps +2
  466. X.PE
  467. X.ce 1
  468. XFigure 3.  A revision tree with one side branch
  469. X.sp
  470. X.IP "\fIDistributed development and customer modifications\fR"
  471. X.sp 0
  472. XAssume a situation as in Figure 2, where revision 1.3 is in operation
  473. Xat several customer sites,
  474. Xwhile release 2 is in development.
  475. XCustomer sites should use RCS to store the distributed software.
  476. XHowever, customer modifications should not be placed on the same branch
  477. Xas the distributed source; instead, they should be placed on a side branch.
  478. XWhen the next software distribution arrives,
  479. Xit should be appended to the trunk of
  480. Xthe customer's RCS file, and the customer
  481. Xcan then merge the local modifications back into the new release.
  482. XIn the above example, a
  483. Xcustomer's RCS file would contain the following tree, assuming
  484. Xthat the customer has received revision 1.3, added his local modifications
  485. Xas revision 1.3.1.1, then received revision 2.4, and merged
  486. X2.4 and 1.3.1.1, resulting in 2.4.1.1.
  487. X.ne 7
  488. X.PS  4i
  489. X.ps -2
  490. XR13: box "1.3"
  491. X     line invis
  492. XR21: box invis
  493. X     line invis
  494. XR22: box invis
  495. X     line invis
  496. XR24: box "2.4"
  497. X     line invis
  498. XR25: box invis
  499. X     line invis
  500. X     arrow from R13.e to R24.w
  501. X     line invis down from R21.s
  502. XRB1: box "1.3.1.1"
  503. X     arrow from R13.s to RB1.w
  504. X     right
  505. X     line invis down from R25.s
  506. XRB2: box "2.4.1.1"
  507. X     arrow from R24.s to RB2.w
  508. X.ps +2
  509. X.PE
  510. X.ce 1
  511. XFigure 4.  A customer's revision tree with local modifications.
  512. X.sp 1
  513. XThis approach is actually practiced in the CSNET project,
  514. Xwhere several universities and a company cooperate
  515. Xin developing a national computer network.
  516. X.IP "\fIParallel development\fR"
  517. X.sp 0
  518. XSometimes it is desirable to explore an alternate design or
  519. Xa different implementation technique in parallel with the
  520. Xmain line development.  Such development
  521. Xshould be carried out on a side branch.
  522. XThe experimental changes may later be moved into the main line, or abandoned.
  523. X.IP "\fIConflicting updates\fR"
  524. X.sp 0
  525. XA common occurrence is that one programmer
  526. Xhas checked out a revision, but cannot complete the assignment
  527. Xfor some reason.  In the meantime, another person
  528. Xmust perform another modification
  529. Ximmediately.  In that case, the second person should check-out the same revision,
  530. Xmodify it, and check it in on a side branch, for later merging.
  531. X.PP
  532. XEvery node in a revision tree consists of the following attributes:
  533. Xa revision number, a check-in date and time, the author's identification,
  534. Xa log entry, a state and the actual text.  All these attributes
  535. Xare determined at the time the revision is checked in.
  536. XThe state attribute indicates the status of a revision.
  537. XIt is set automatically to `experimental' during check-in.
  538. XA revision can later be promoted to a higher status, for example
  539. X`stable' or `released'.  The set of states is user-defined.
  540. X.NH 2
  541. XRevisions are represented as deltas
  542. X.PP
  543. XFor conserving space, RCS stores revisions in the form
  544. Xof deltas, i.e., as differences between revisions.
  545. XThe user interface completely hides this fact.
  546. X.PP
  547. XA delta is a sequence of edit commands that transforms one string
  548. Xinto another.  The deltas employed by RCS are line-based, which means
  549. Xthat the only edit commands allowed are insertion and deletion of lines.
  550. XIf a single character in a line is changed, the
  551. Xedit scripts consider the entire line changed.
  552. XThe program \fIdiff\fR\u2\d
  553. Xproduces a small, line-based delta between pairs of text files.
  554. XA character-based edit script would take much longer to compute,
  555. Xand would not be significantly shorter.
  556. X.PP
  557. XUsing deltas is a classical space-time tradeoff: deltas reduce the
  558. Xspace consumed, but increase access time.
  559. XHowever, a version control tool should impose as little delay
  560. Xas possible on programmers.
  561. XExcessive delays discourage the use of version controls,
  562. Xor induce programmers to take shortcuts that compromise system integrity.
  563. XTo gain reasonably fast access time for both editing and compiling,
  564. XRCS arranges deltas in the following way.
  565. XThe most recent revision on the trunk is stored intact.
  566. XAll other revisions on the trunk are stored as reverse deltas.
  567. XA reverse delta describes how to go backward in the development history:
  568. Xit produces the desired revision if applied to the successor of that revision.
  569. XThis implementation has the advantage
  570. Xthat extraction of the latest revision is a simple and fast copy
  571. Xoperation.
  572. XAdding a new revision to the trunk is also fast: \fIci\fR simply
  573. Xadds the new revision intact, replaces the previous
  574. Xrevision with a reverse delta, and keeps the rest of the old deltas.
  575. XThus, \fIci\fR requires the computation
  576. Xof only one new delta.
  577. X.PP
  578. XBranches need special treatment.  The naive solution would be to
  579. Xstore complete copies for the tips of all branches.
  580. XClearly, this approach would cost too much space.  Instead,
  581. XRCS uses \fIforward\fR deltas for branches.  Regenerating a revision
  582. Xon a side branch proceeds as follows.  First, extract the latest revision
  583. Xon the trunk; secondly, apply reverse deltas until the fork revision for
  584. Xthe branch is obtained; thirdly, apply forward deltas until the desired
  585. Xbranch revision is reached.  Figure 5 illustrates a tree with
  586. Xone side branch.  Triangles pointing to the left and right represent
  587. Xreverse and forward deltas, respectively.
  588. X.ne 8
  589. X.PS  4i
  590. X.ps -2
  591. Xdefine BD X [line invis $1 right .5;
  592. Xline up .3 then left .5 down .3 then right .5 down .3 then up .3] X
  593. X
  594. Xdefine FD X [line invis $1 right .5;
  595. Xline left .5 down .3 then up .6 then right .5 down .3;] X
  596. X
  597. Xright
  598. XD11:    BD(" 1.1")
  599. X    arrow right from D11.e
  600. XD12:    BD(" 1.2")
  601. X    arrow  right from D12.e
  602. XD13:    BD(" 1.3")
  603. X    arrow  right from D13.e
  604. XD21:    BD(" 2.1")
  605. X    arrow  right from D21.e
  606. XD22:    box "2.2"
  607. X    line invis down from D21.s
  608. XF1:     FD("1.3.1.1 ")
  609. X    arrow from D13.se to F1.w
  610. X    arrow from F1.e right
  611. X    right
  612. XF2:     FD("1.3.1.2 ")
  613. X.ps +2
  614. X.PE
  615. X.ce 1
  616. XFigure 5.  A revision tree with reverse and forward deltas.
  617. X.sp 0
  618. X.PP
  619. XAlthough implementing fast check-out for the latest trunk revision,
  620. Xthis arrangement has the disadvantage that generation of other revisions
  621. Xtakes time proportional to the number of deltas applied.  For example,
  622. Xregenerating the branch tip in Figure 5 requires application of five
  623. Xdeltas (including the initial one).  Since usage statistics show that
  624. Xthe latest trunk revision is the one that is retrieved in 95 per cent
  625. Xof all cases (see the section on usage statistics), biasing check-out time
  626. Xin favor of that revision results in significant savings.
  627. XHowever, careful implementation of the delta application process is
  628. Xnecessary to provide low retrieval overhead for other revisions, in
  629. Xparticular for branch tips.
  630. X.PP
  631. XThere are several techniques for delta application.
  632. XThe naive one is to pass each delta to a general-purpose text editor.
  633. XA prototype of RCS invoked the UNIX editor \fIed\fR both
  634. Xfor applying deltas and for expanding the identification markers.
  635. XAlthough easy to implement, performance was poor, owing to the
  636. Xhigh start-up costs and excess generality of \fIed\fR.  An intermediate
  637. Xversion of RCS used a special-purpose, stream-oriented editor.
  638. XThis technique reduced the cost of applying a delta to the cost of
  639. Xchecking out the latest trunk revision.  The reason for this behavior
  640. Xis that each delta application involves a complete pass over
  641. Xthe preceding revision.
  642. X.PP
  643. XHowever, there is a much better algorithm.  Note that the deltas are
  644. Xline oriented and that most of the work of a stream editor involves
  645. Xcopying unchanged lines from one revision to the next.  A faster
  646. Xalgorithm avoids unnecessary copying of character strings by using
  647. Xa \fIpiece table\fR.
  648. XA piece table is a one-dimensional array, specifying how a given
  649. Xrevision is `pieced together' from lines in the RCS file.
  650. XSuppose piece table \fIPT\dr\u\fR represents revision \fIr\fR.
  651. XThen \fIPT\dr\u[i]\fR contains the starting position of line \fIi\fR
  652. Xof revision \fIr\fR.
  653. XApplication of the next delta transforms piece table \fIPT\dr\u\fR
  654. Xinto \fIPT\dr+1\u\fR.  For instance, a delete command removes a
  655. Xseries of entries from the piece table.  An insertion command inserts
  656. Xnew entries, moving the entries following the insertion point further down the
  657. Xarray.  The inserted entries point to the text lines in the delta.
  658. XThus, no I/O is involved except for reading the delta itself.  When all
  659. Xdeltas have been applied to the piece table, a sequential pass
  660. Xthrough the table looks up each line in the RCS file and copies it to
  661. Xthe output file, updating identification markers at the same time.
  662. XOf course, the RCS file must permit random access, since the copied
  663. Xlines are scattered throughout that file.  Figure 6 illustrates an
  664. XRCS file with two revisions and the corresponding piece tables.
  665. X.ne 13
  666. X.sp 6
  667. X.ce 1
  668. X\fIFigure 6 is not available.\fP
  669. X.sp 5
  670. X.ce 1
  671. XFigure 6.  An RCS file and its piece tables
  672. X.sp 0
  673. X.PP
  674. XThe piece table approach has the property that the time for applying a single
  675. Xdelta is roughly determined by the size of the delta, and not by the
  676. Xsize of the revision.  For example, if a delta is
  677. X10 per cent of the size of a revision, then applying it takes only
  678. X10 per cent of the time to generate the latest trunk revision.  (The stream
  679. Xeditor would take 100 per cent.)
  680. X.PP
  681. XThere is an important alternative for representing deltas that affects
  682. Xperformance.  SCCS\u3\d,
  683. Xa precursor of RCS, uses \fIinterleaved\fR deltas.
  684. XA file containing interleaved deltas is partitioned into blocks of lines.
  685. XEach block has a header that specifies to which revision(s) the block
  686. Xbelongs.  The blocks are sorted out in such a way that a single
  687. Xpass over the file can pick up all the lines belonging to a given
  688. Xrevision.  Thus, the regeneration time for all revisions is the same:
  689. Xall headers must be inspected, and the associated blocks either copied
  690. Xor skipped.  As the number of revisions increases, the cost of retrieving
  691. Xany revision is much higher than the cost of checking out the
  692. Xlatest trunk revision with reverse deltas.  A detailed comparison
  693. Xof SCCS's interleaved deltas and RCS's reverse deltas can be found
  694. Xin Reference 4.
  695. XThis reference considers the version of RCS with the
  696. Xstream editor only.  The piece table method improves performance
  697. Xfurther, so that RCS is always faster than SCCS, except if 10
  698. Xor more deltas are applied.
  699. X.PP
  700. XAdditional speed-up for both delta methods can be obtained by caching
  701. Xthe most recently generated revision, as has been implemented in DSEE.\u5\d
  702. XWith caching, access time to frequently used revisions can approach normal file
  703. Xaccess time, at the cost of some additional space.
  704. X.NH
  705. XLocking: A Controversial Issue
  706. X.PP
  707. XThe locking mechanism for RCS was difficult to design.
  708. XThe problem and its solution are first presented in their `pure' form,
  709. Xfollowed by a discussion of the complications
  710. Xcaused by `real-world' considerations.
  711. X.PP
  712. XRCS must prevent two or more persons from depositing competing changes of the
  713. Xsame revision.
  714. XSuppose two programmers check out revision 2.4 and
  715. Xmodify it.  Programmer A checks in a revision before programmer B\&.
  716. XUnfortunately, programmer B has not seen A's
  717. Xchanges, so the effect is that A's changes are covered up by B's deposit.
  718. XA's changes are not lost since all revisions
  719. Xare saved, but they are confined to a single revision.\(dd
  720. X.FS \(dd
  721. XNote that this problem is entirely different from the atomicity problem.
  722. XAtomicity means that
  723. Xconcurrent update operations on the same RCS file cannot be permitted,
  724. Xbecause that may result in inconsistent data.
  725. XAtomic updates are essential (and implemented in RCS),
  726. Xbut do not solve the conflict discussed here.
  727. X.FE
  728. X.PP
  729. XThis conflict is prevented in RCS by locking.
  730. XWhenever someone intends to edit a revision (as opposed
  731. Xto reading or compiling it), the revision should be checked out
  732. Xand locked,
  733. Xusing the \fI\-l\fR option on \fIco\fR.  On subsequent check-in,
  734. X\fIci\fR tests the lock and then removes it.
  735. XAt most one programmer at a time may
  736. Xlock a particular revision, and only this programmer may check in
  737. Xthe succeeding revision.
  738. XThus, while a revision is locked, it is the exclusive responsibility
  739. Xof the locker.
  740. X.PP
  741. XAn important maxim for software tools like RCS is that they must
  742. Xnot stand in the way of making progress with a project.
  743. XThis consideration leads to several weakenings of the locking mechanism.
  744. XFirst of all, even if a revision is locked, it can
  745. Xstill be checked out.  This is necessary if other people
  746. Xwish to compile or inspect the locked revision
  747. Xwhile the next one is in preparation.  The only operations they
  748. Xcannot do are to lock the revision or to check in the succeeding one.  Secondly,
  749. Xcheck-in operations on other branches in the RCS file are still possible; the
  750. Xlocking of one revision does not affect any other revision.
  751. XThirdly, revisions are occasionally locked for a long period of time
  752. Xbecause a programmer is absent or otherwise unable to complete
  753. Xthe assignment.  If another programmer has to make a pressing change,
  754. Xthere are the following three alternatives for making progress:
  755. Xa) find out who is holding the lock and ask that person to release it;
  756. Xb) check out the locked revision, modify it, check it
  757. Xin on a branch, and merge the changes later;
  758. Xc) break the lock.  Breaking a lock leaves a highly visible
  759. Xtrace, namely an electronic mail message that is sent automatically to the
  760. Xholder of the lock, recording the breaker and a commentary requested from him.
  761. XThus, breaking locks is tolerated under certain circumstances,
  762. Xbut will not go unnoticed.
  763. XExperience has shown that the automatic mail message attaches a high enough
  764. Xstigma to lock breaking,
  765. Xsuch that programmers break locks only in real emergencies,
  766. Xor when a co-worker resigns and leaves locked revisions behind.
  767. X.PP
  768. XIf an RCS file is private, i.e., when a programmer owns an RCS file
  769. Xand does not expect anyone else to perform check-in operations,
  770. Xlocking is an unnecessary nuisance.
  771. XIn this case,
  772. Xthe `strict locking feature' discussed earlier may be disabled,
  773. Xprovided that file protection
  774. Xis set such that only the owner may write the RCS file.
  775. XThis has the effect that only the owner can check-in revisions,
  776. Xand that no lock is needed for doing so.
  777. X.PP
  778. XAs added protection,
  779. Xeach RCS file contains an access list that specifies the users
  780. Xwho may execute update operations.  If an access list is empty,
  781. Xonly normal UNIX file protection applies.  Thus, the access list is
  782. Xuseful for restricting the set of people who would otherwise have update
  783. Xpermission.  Just as with locking, the access list
  784. Xhas no effect on read-only operations such as \fIco\fR.  This approach
  785. Xis consistent with the UNIX philosophy of openness, which contributes
  786. Xto a productive software development environment.
  787. X.NH
  788. XConfiguration Management
  789. X.PP
  790. XThe preceding sections described how RCS deals with revisions of individual
  791. Xcomponents; this section discusses how to handle configurations.
  792. XA configuration is a set of revisions, where each revision comes
  793. Xfrom a different revision group, and the revisions are selected
  794. Xaccording to a certain criterion.
  795. XFor example,
  796. Xin order to build a functioning compiler, the `right'
  797. Xrevisions from the scanner, the parser, the optimizer
  798. Xand the code generator must be combined.
  799. XRCS, in conjunction with MAKE,
  800. Xprovides a number of facilities to effect a smooth selection.
  801. X.NH 2
  802. XRCS Selection Functions
  803. X.PP
  804. X.IP "\fIDefault selection\fR"
  805. X.sp 0
  806. XDuring development, the usual selection criterion is to choose
  807. Xthe latest revision of all components.  The \fIco\fR command
  808. Xmakes this selection by default.  For example, the command
  809. X.D(
  810. Xco  *,v
  811. X.D)
  812. Xretrieves the latest revision on the default branch of each RCS file
  813. Xin the current directory.
  814. XThe default branch is usually the trunk, but may be
  815. Xset to be a side branch.
  816. XSide branches as defaults are needed in distributed software development,
  817. Xas discussed in the section on the RCS revision tree.
  818. X.sp
  819. X.IP "\fIRelease based selection\fR"
  820. X.sp 0
  821. XSpecifying a release or branch number selects the latest revision in
  822. Xthat release or branch.
  823. XFor instance,
  824. X.D(
  825. Xco  \-r2  *,v
  826. X.D)
  827. Xretrieves the latest revision with release number 2 from each RCS file.
  828. XThis selection is convenient if a release has been completed and
  829. Xdevelopment has moved on to the next release.
  830. X.sp
  831. X.IP "\fIState and author based selection\fR"
  832. X.sp 0
  833. XIf the highest level number within a given release number
  834. Xis not the desired one,
  835. Xthe state attribute can help.  For example,
  836. X.D(
  837. Xco  \-r2  \-sReleased  *,v
  838. X.D)
  839. Xretrieves the latest revision with release number 2 whose state attribute
  840. Xis `Released'.
  841. XOf course, the state attribute has to be set appropriately, using the
  842. X\fIci\fR or \fIrcs\fR commands.
  843. XAnother alternative is to select a revision by its author,
  844. Xusing the \fI\-w\fR option.
  845. X.sp
  846. X.IP "\fIDate based selection\fR"
  847. X.sp 0
  848. XRevisions may also be selected by date.
  849. XSuppose a release of an entire system was
  850. Xcompleted and current on March 4, at 1:00 p.m. local time.  Then the command
  851. X.D(
  852. Xco  \-d'March 4, 1:00 pm LT'  *,v
  853. X.D)
  854. Xchecks out all the components of that release, independent of the numbering.
  855. XThe \fI\-d\fR option specifies a `cutoff date', i.e.,
  856. Xthe revision selected has a check-in date that
  857. Xis closest to, but not after the date given.
  858. X.IP "\fIName based selection\fR"
  859. X.sp 0
  860. XThe most powerful selection function is based on assigning symbolic
  861. Xnames to revisions and branches.
  862. XIn large systems, a single release number or date is not sufficient
  863. Xto collect the appropriate revisions from all groups.
  864. XFor example, suppose one wishes to combine release 2
  865. Xof one subsystem and release 15 of another.
  866. XMost likely, the creation dates of those releases differ also.
  867. XThus, a single revision number or date passed to the \fIco\fR command
  868. Xwill not suffice to select the right revisions.
  869. XSymbolic revision numbers solve this problem.
  870. XEach RCS file may contain a set of symbolic names that are mapped
  871. Xto numeric revision numbers.  For example, assume
  872. Xthe symbol \fIV3\fR is bound to release number 2 in file \fIs,v\fR, and to
  873. Xrevision number 15.9 in \fIt,v\fR.
  874. XThen the single command
  875. X.D(
  876. Xco  \-rV3  s,v  t,v
  877. X.D)
  878. Xretrieves the latest revision of release 2 from \fIs,v\fR,
  879. Xand revision 15.9 from \fIt,v\fR.
  880. XIn a large system with many modules, checking out all
  881. Xrevisions with one command greatly simplifies configuration management.
  882. X.PP
  883. XJudicious use of symbolic revision numbers helps with organizing
  884. Xlarge configurations.
  885. XA special command, \fIrcsfreeze\fR,
  886. Xassigns a symbolic revision number to a selected revision
  887. Xin every RCS file.
  888. X\fIRcsfreeze\fR effectively freezes a configuration.
  889. XThe assigned symbolic revision number selects all components
  890. Xof the configuration.
  891. XIf necessary, symbolic numbers
  892. Xmay even be intermixed with numeric ones.  Thus, \fIV3.5\fR in the
  893. Xabove example
  894. Xwould select revision 2.5 in \fIs,v\fR and branch 15.9.5 in \fIt,v\fR.
  895. X.PP
  896. XThe options \fI\-r\fR, \fI\-s\fR, \fI\-w\fR and \fI\-d\fR
  897. Xmay be combined.  If a branch is given, the latest revision
  898. Xon that branch satisfying all conditions is retrieved;
  899. Xotherwise, the default branch is used.
  900. X.NH 2
  901. XCombining MAKE and RCS
  902. X.PP
  903. XMAKE\u1\d
  904. Xis a program that processes configurations.
  905. XIt is driven by configuration specifications
  906. Xrecorded in a special file, called a `Makefile'.
  907. XMAKE avoids redundant processing steps
  908. Xby comparing creation dates of source and processed objects.
  909. XFor example, when instructed to compile all
  910. Xmodules of a given system, it only recompiles
  911. Xthose source modules that were changed
  912. Xsince they were processed last.
  913. X.PP
  914. XMAKE has been extended with an auto-checkout feature for RCS.*
  915. X.FS *
  916. XThis auto-checkout extension is available only in some versions of MAKE,
  917. Xe.g. GNU MAKE.
  918. X.FE
  919. XWhen a certain file to be processed is not present,
  920. XMAKE attempts a check-out operation.
  921. XIf successful, MAKE performs the required processing, and then deletes
  922. Xthe checked out file to conserve space.
  923. XThe selection parameters discussed above can be passed to MAKE
  924. Xeither as parameters, or directly embedded in the Makefile.
  925. XMAKE has also been extended to search the subdirectory named \fIRCS\fR
  926. Xfor needed files, rather than just the current working directory.
  927. XHowever, if a working file is present, MAKE totally ignores the corresponding
  928. XRCS file and uses the working file.
  929. X(In newer versions of MAKE distributed by AT&T and others,
  930. Xauto-checkout can be
  931. Xachieved with the rule DEFAULT, instead of a special extension of MAKE.
  932. XHowever, a file checked out by the rule DEFAULT
  933. Xwill not be deleted after processing. \fIRcsclean\fR can be
  934. Xused for that purpose.)
  935. X.PP
  936. XWith auto-checkout, RCS/MAKE can effect a selection rule
  937. Xespecially tuned for multi-person software development and maintenance.
  938. XIn these situations,
  939. Xprogrammers should obtain configurations that consist of
  940. Xthe revisions they have personally checked out plus the latest
  941. Xchecked in revision of all other revision groups.
  942. XThis schema can be set up as follows.
  943. X.PP
  944. XEach programmer chooses a working directory
  945. Xand places into it a symbolic link, named \fIRCS\fR,
  946. Xto the directory containing the relevant RCS files.
  947. XThe symbolic link makes sure that \fIco\fR and \fIci\fR
  948. Xoperations need only specify the working files, and that
  949. Xthe Makefile need not be changed.
  950. XThe programmer then checks out the needed files and modifies them.
  951. XIf MAKE is invoked,
  952. Xit composes configurations by selecting those
  953. Xrevisions that are checked out, and the rest from the
  954. Xsubdirectory \fIRCS\fR.
  955. XThe latter selection may be controlled by a symbolic
  956. Xrevision number or any of the other selection criteria.
  957. XIf there are several programmers editing in separate working directories,
  958. Xthey are insulated from each other's changes until checking in their
  959. Xmodifications.
  960. X.PP
  961. XSimilarly, a maintainer can recreate an older configuration
  962. Xby starting to work in an empty working directory.
  963. XDuring the initial MAKE invocation, all revisions are selected from RCS files.
  964. XAs the maintainer checks out files and modifies them,
  965. Xa new configuration is gradually built up.
  966. XEvery time MAKE is invoked, it substitutes the modified revisions
  967. Xinto the configuration being manipulated.
  968. X.PP
  969. XA final application of RCS is to use it for storing Makefiles.
  970. XRevision groups of Makefiles represent
  971. Xmultiple versions of configurations.
  972. XWhenever a configuration is baselined or distributed,
  973. Xthe best approach is to unambiguously fix
  974. Xthe configuration with a symbolic revision number by calling
  975. X\fIrcsfreeze\fR,
  976. Xto embed that symbol into the Makefile, and to
  977. Xcheck in the Makefile (using the same symbolic revision number).
  978. XWith this approach, old configurations
  979. Xcan be regenerated easily and reliably.
  980. X.NH
  981. XUsage Statistics
  982. X.PP
  983. XThe following usage statistics were collected on two DEC VAX-11/780
  984. Xcomputers of the Purdue Computer Science Department.  Both machines
  985. Xare mainly used for research purposes.  Thus, the data
  986. Xreflect an environment in which the majority of projects
  987. Xinvolve prototyping and advanced software development,
  988. Xbut relatively little long-term maintenance.
  989. X.PP
  990. XFor the first experiment,
  991. Xthe \fIci\fR and \fIco\fR operations were instrumented
  992. Xto log the number of backward and forward deltas applied.
  993. XThe data were collected during a 13 month period
  994. Xfrom Dec. 1982 to Dec. 1983.
  995. XTable I summarizes the results.
  996. X.sp 0
  997. X.nr VS 12p
  998. X.vs 12p
  999. X.TS
  1000. Xcenter,box,tab(#);
  1001. Xc|c|c|c|c s|c s
  1002. Xc|c|c|c|c s|c s
  1003. Xl|n|n|n|n n|n n.
  1004. XOperation#Total#Total deltas#Mean deltas#Operations#Branch
  1005. X     #operations #applied#applied#with >1 delta#operations
  1006. X_
  1007. Xco     # 7867# 9320#1.18#509#(6%)#203#(3%)
  1008. Xci     # 3468# 2207#0.64# 85#(2%)# 75#(2%)
  1009. Xci & co#11335#11527#1.02#594#(5%)#278#(2%)
  1010. X.TE
  1011. X.ce 1
  1012. XTable I.  Statistics for \fIco\fR and \fIci\fR operations.
  1013. X.nr VS 18p
  1014. X.vs 18p
  1015. X.PP
  1016. XThe first two lines show statistics for check-out and check-in;
  1017. Xthe third line shows the combination.
  1018. XRecall that \fIci\fR performs an implicit check-out to obtain
  1019. Xa revision for computing the delta.
  1020. XIn all measures presented, the most recent revision (stored intact)
  1021. Xcounts as one delta.  The number of deltas applied represents
  1022. Xthe number of passes necessary, where the first `pass' is a copying step.
  1023. X.PP
  1024. XNote that the check-out operation is executed more than
  1025. Xtwice as frequently as the check-in operation.
  1026. XThe fourth column gives the mean number of deltas
  1027. Xapplied in all three cases.
  1028. XFor \fIci\fR, the mean number of deltas applied is less
  1029. Xthan one.
  1030. XThe reasons are that the initial check-in requires no delta at all, and that
  1031. Xthe only time \fIci\fR requires more than one delta is for branches.
  1032. XColumn 5 shows the actual number of operations that applied more than one
  1033. Xdelta.
  1034. XThe last column indicates that branches were not used often.
  1035. X.PP
  1036. XThe last three columns demonstrate that the most recent trunk revision
  1037. Xis by far the most frequently accessed.
  1038. XFor RCS, check-out of
  1039. Xthis revision is a simple copy operation, which is the absolute minimum
  1040. Xgiven the copy-semantics of \fIco\fR.
  1041. XAccess to older revisions and branches
  1042. Xis more common in non-academic environments,
  1043. Xyet even if access to older deltas were an order
  1044. Xof magnitude more frequent,
  1045. Xthe combined average number of deltas applied would still be below 1.2.
  1046. XSince RCS is faster than SCCS until up to 10 delta applications,
  1047. Xreverse deltas are clearly the method of choice.
  1048. X.PP
  1049. XThe second experiment, conducted in March of 1984,
  1050. Xinvolved surveying the existing RCS files
  1051. Xon our two machines.  The goal was to determine the mean number of
  1052. Xrevisions per RCS file, as well as the space consumed by them.
  1053. XTable II shows the results.  (Tables I and II were produced at different
  1054. Xtimes and are unrelated.)
  1055. X.sp 0
  1056. X.nr VS 12p
  1057. X.vs 12p
  1058. X.TS
  1059. Xcenter,box,tab(#);
  1060. Xc | c | c | c | c | c | c
  1061. Xc | c | c | c | c | c | c
  1062. Xl | n | n | n | n | n | n.
  1063. X      #Total RCS#Total#Mean#Mean size of#Mean size of#Overhead
  1064. X      #files#revisions#revisions#RCS files#revisions
  1065. X_
  1066. XAll files #8033#11133#1.39#6156#5585#1.10
  1067. XFiles with#1477# 4578#3.10#8074#6041#1.34
  1068. X\(>= 2 deltas
  1069. X.TE
  1070. X.ce 1
  1071. XTable II.  Statistics for RCS files.
  1072. X.nr VS 18p
  1073. X.vs 18p
  1074. X.PP
  1075. XThe mean number of revisions per RCS file is 1.39.
  1076. XColumns 5 and 6 show the mean sizes (in bytes) of an RCS file
  1077. Xand of the latest revision of each RCS file, respectively.
  1078. XThe `overhead' column contains the ratio of the mean sizes.
  1079. XAssuming that all revisions in an RCS file are approximately the same size,
  1080. Xthis ratio gives a measure of the space consumed by the extra revisions.
  1081. X.PP
  1082. XIn our sample, over 80 per cent of the RCS files contained only a single revision.
  1083. XThe reason is that our
  1084. Xsystems programmers routinely check in all source files
  1085. Xon the distribution tapes, even though they may never touch them again.
  1086. XTo get a better indication of how much space savings are possible
  1087. Xwith deltas, all measures with those files
  1088. Xthat contained 2 or more revisions were recomputed.  Only for those files
  1089. Xis RCS necessary.
  1090. XAs shown in the second line, the average number of revisions for those files is
  1091. X3.10, with an overhead of 1.34.  This means that the extra 2.10 deltas
  1092. Xrequire 34 per cent extra space, or
  1093. X16 per cent per extra revision.
  1094. XRochkind\u3\d
  1095. Xmeasured the space consumed by SCCS, and
  1096. Xreported an average of 5 revisions per group
  1097. Xand an overhead of 1.37 (or about 9 per cent per extra revision).
  1098. XIn a later paper, Glasser\u6\d
  1099. Xobserved an average of 7 revisions per group in a single, large project,
  1100. Xbut provided no overhead figure.
  1101. XIn his paper on DSEE\u5\d,
  1102. XLeblang reported that delta storage combined with blank compression
  1103. Xresults in an overhead of a mere 1\-2 per cent per revision.
  1104. XSince leading blanks accounted for about 20 per cent of the surveyed Pascal
  1105. Xprograms, a revision group with 5\-10 members was smaller
  1106. Xthan a single cleartext copy.
  1107. X.PP
  1108. XThe above observations demonstrate clearly that the space needed
  1109. Xfor extra revisions is small.  With delta storage, the luxury of
  1110. Xkeeping multiple revisions online is certainly affordable.
  1111. XIn fact, introducing a system with delta storage may reduce
  1112. Xstorage requirements, because programmers often save back-up copies
  1113. Xanyway.  Since back-up copies are stored much more efficiently with deltas,
  1114. Xintroducing a system such as RCS may
  1115. Xactually free a considerable amount of space.
  1116. X.NH
  1117. XSurvey of Version Control Tools
  1118. X.PP
  1119. XThe need to keep back-up copies of software arose when
  1120. Xprograms and data were no longer stored on paper media, but were entered
  1121. Xfrom terminals and stored on disk.
  1122. XBack-up copies are desirable for reliability, and many modern editors
  1123. Xautomatically save a back-up copy for every file touched.
  1124. XThis strategy
  1125. Xis valuable for short-term back-ups, but not suitable for long-term
  1126. Xversion control, since an existing back-up copy is overwritten whenever the
  1127. Xcorresponding file is edited.
  1128. X.PP
  1129. XTape archives are suitable for long-term, offline storage.
  1130. XIf all changed files are dumped on a back-up tape once per day, old revisions
  1131. Xremain accessible.  However, tape archives are unsatisfactory
  1132. Xfor version control in several ways.  First, backing up the file
  1133. Xsystem every 24 hours does not capture intermediate revisions.
  1134. XSecondly, the old revisions are not online,
  1135. Xand accessing them is tedious and time-consuming.
  1136. XIn particular, it is impractical to
  1137. Xcompare several old revisions of a group,
  1138. Xbecause that may require mounting and searching several tapes.
  1139. XTape archives are important fail-safe tools in the
  1140. Xevent of catastrophic disk failures or accidental deletions,
  1141. Xbut they are ill-suited for version control.
  1142. XConversely, version control tools do not obviate the
  1143. Xneed for tape archives.
  1144. X.PP
  1145. XA natural technique for keeping several old revisions online is
  1146. Xto never delete a file.
  1147. XEditing a file
  1148. Xsimply creates a new file with the same
  1149. Xname, but with a different sequence number.
  1150. XThis technique, available as an option in DEC's VMS operating system,
  1151. Xturns out to be inadequate for version control.
  1152. XFirst, it is prohibitively expensive in terms of storage costs,
  1153. Xespecially since no data compression techniques are employed.
  1154. XSecondly, indiscriminately storing every change produces too many
  1155. Xrevisions, and programmers have difficulties distinguishing them.
  1156. XThe proliferation of revisions forces programmers to spend much time on
  1157. Xfinding and deleting useless files.
  1158. XThirdly, most of the support functions like locking, logging,
  1159. Xrevision selection,
  1160. Xand identification described in this paper are not available.
  1161. X.PP
  1162. XAn alternative approach is to separate editing from revision control.
  1163. XThe user may repeatedly edit a given revision,
  1164. Xuntil freezing it with an explicit command.
  1165. XOnce a revision is frozen, it is stored permanently and can no longer be modified.
  1166. X(In RCS, freezing a revisions is done with \fIci\fR.)
  1167. XEditing a frozen revision implicitly creates a new one, which
  1168. Xcan again be changed repeatedly until it is frozen itself.
  1169. XThis approach saves exactly those revisions that the user
  1170. Xconsiders important, and keeps the number of revisions manageable.
  1171. XIBM's CLEAR/CASTER\u7\d,
  1172. XAT&T's SCCS\u3\d,
  1173. XCMU's SDC\u8\d
  1174. Xand DEC's CMS\u9\d,
  1175. Xare examples of version control systems using this approach.
  1176. XCLEAR/CASTER maintains a data base of programs, specifications,
  1177. Xdocumentation and messages, using deltas.
  1178. XIts goal is to provide control over the development process from a
  1179. Xmanagement viewpoint.
  1180. XSCCS stores multiple revisions of source text in an ancestral tree,
  1181. Xrecords a log entry for each revision,
  1182. Xprovides access control, and has facilities
  1183. Xfor uniquely identifying each revision.
  1184. XAn efficient delta technique
  1185. Xreduces the space consumed by each revision group.
  1186. XSDC is much simpler than SCCS because it stores not more than
  1187. Xtwo revisions.  However, it maintains a complete log for all old
  1188. Xrevisions, some of which may be on back-up tape.
  1189. XCMS, like SCCS, manages tree-structured revision groups,
  1190. Xbut offers no identification mechanism.
  1191. X.PP
  1192. XTools for dealing with configurations are still in a state of flux.
  1193. XSCCS, SDC and CMS can be combined with MAKE or MAKE-like programs.
  1194. XSince flexible selection rules are missing from all these tools,
  1195. Xit is sometimes difficult
  1196. Xto specify precisely which revision of each group
  1197. Xshould be passed to MAKE for building a desired configuration.
  1198. XThe Xerox Cedar system\u10\d
  1199. Xprovides a `System Modeller' that can rebuild
  1200. Xa configuration from an arbitrary set of module revisions.
  1201. XThe revisions of a module are only distinguished by creation time,
  1202. Xand there is no tool for managing groups.
  1203. XSince the selection rules are primitive,
  1204. Xthe System Modeller appears to be somewhat tedious to use.
  1205. XApollo's DSEE\u5\d
  1206. Xis a sophisticated software engineering environment.
  1207. XIt manages revision groups in a way similar to SCCS and CMS.  Configurations
  1208. Xare built using `configuration threads'.
  1209. XA configuration thread states which revision of each group
  1210. Xnamed in a configuration should be chosen.
  1211. XA configuration thread may contain dynamic specifiers
  1212. X(e.g., `choose the revisions I am currently working on,
  1213. Xand the most recent revisions otherwise'), which are bound
  1214. Xautomatically at build time.
  1215. XIt also provides a notification mechanism for alerting
  1216. Xmaintainers about the need to rebuild a system after a change.
  1217. X.PP
  1218. XRCS is based on a general model for describing
  1219. Xmulti-version/multi-configuration systems\u11\d.
  1220. XThe model describes systems using AND/OR graphs, where AND nodes represent
  1221. Xconfigurations, and OR nodes represent version groups.
  1222. XThe model gives rise to a suit of selection rules for
  1223. Xcomposing configurations, almost all of which are implemented in RCS.
  1224. XThe revisions selected by RCS are passed to MAKE for configuration building.
  1225. XRevision group management is modelled after SCCS.
  1226. XRCS retains SCCS's best features,
  1227. Xbut offers a significantly simpler user interface,
  1228. Xflexible selection rules, adequate integration with MAKE
  1229. Xand improved identification.
  1230. XA detailed comparison of RCS and SCCS appears in Reference 4.
  1231. X.PP
  1232. XAn important component of all revision control systems
  1233. Xis a program for computing deltas.
  1234. XSCCS and RCS use the program \fIdiff\fR\u2\d,
  1235. Xwhich first computes the longest common substring of two
  1236. Xrevisions, and then produces the delta from that substring.
  1237. XThe delta is simply an edit script consisting of deletion and
  1238. Xinsertion commands that generate one revision from the other.
  1239. X.PP
  1240. XA delta based on a longest common substring is not necessarily minimal,
  1241. Xbecause it does not take advantage of crossing block moves.
  1242. XCrossing block moves arise if two or more blocks of lines
  1243. X(e.g., procedures)
  1244. Xappear in a different order in two revisions.
  1245. XAn edit script derived from a longest common substring
  1246. Xfirst deletes the shorter of the two blocks, and then reinserts it.
  1247. XHeckel\u12\d
  1248. Xproposed an algorithm for detecting block moves, but
  1249. Xsince the algorithm is based on heuristics,
  1250. Xthere are conditions
  1251. Xunder which the generated delta is far from minimal.
  1252. XDSEE uses this algorithm combined with blank compression,
  1253. Xapparently with satisfactory overall results.
  1254. XA new algorithm that is guaranteed to produce a minimal delta based on
  1255. Xblock moves appears in Reference 13.
  1256. XA future release of RCS will use this algorithm.
  1257. X.PP
  1258. X\fIAcknowledgements\fR:
  1259. XMany people have helped make RCS a success by contributed criticisms, suggestions,
  1260. Xcorrections, and even whole new commands (including manual pages).
  1261. XThe list of people is too long to be
  1262. Xreproduced here, but my sincere thanks for their help and
  1263. Xgoodwill goes to all of them.
  1264. X.sp
  1265. X.nr VS 12p
  1266. X.vs 12p
  1267. X.SH
  1268. XAppendix: Synopsis of RCS Operations
  1269. X.LP
  1270. X.IP "\fIci\fP \fB\- check in revisions\fP"
  1271. X.sp 0
  1272. X\fICi\fR stores the contents of a working file into the
  1273. Xcorresponding RCS file as a new revision.
  1274. XIf the RCS file doesn't exist, \fIci\fR creates it.
  1275. X\fICi\fR removes the working file, unless one of the options
  1276. X\fI\-u\fR or \fI\-l\fR is present.
  1277. XFor each check-in, \fIci\fR asks for a commentary
  1278. Xdescribing the changes relative to the previous revision.
  1279. X.sp 1
  1280. X\fICi\fR assigns the revision number given by the \fI\-r\fR option;
  1281. END_OF_FILE
  1282.   if test 49803 -ne `wc -c <'rcs.ms.01'`; then
  1283.     echo shar: \"'rcs.ms.01'\" unpacked with wrong size!
  1284.   fi
  1285.   # end of 'rcs.ms.01'
  1286. fi
  1287. if test -f 'src/rcskeys.c' -a "${1}" != "-c" ; then 
  1288.   echo shar: Will not clobber existing file \"'src/rcskeys.c'\"
  1289. else
  1290.   echo shar: Extracting \"'src/rcskeys.c'\" \(2404 characters\)
  1291.   sed "s/^X//" >'src/rcskeys.c' <<'END_OF_FILE'
  1292. X/*
  1293. X *                     RCS keyword table and match operation
  1294. X */
  1295. X
  1296. X/* Copyright (C) 1982, 1988, 1989 Walter Tichy
  1297. X   Copyright 1990 by Paul Eggert
  1298. X   Distributed under license by the Free Software Foundation, Inc.
  1299. X
  1300. XThis file is part of RCS.
  1301. X
  1302. XRCS is free software; you can redistribute it and/or modify
  1303. Xit under the terms of the GNU General Public License as published by
  1304. Xthe Free Software Foundation; either version 1, or (at your option)
  1305. Xany later version.
  1306. X
  1307. XRCS is distributed in the hope that it will be useful,
  1308. Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
  1309. XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1310. XGNU General Public License for more details.
  1311. X
  1312. XYou should have received a copy of the GNU General Public License
  1313. Xalong with RCS; see the file COPYING.  If not, write to
  1314. Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1315. X
  1316. XReport problems and direct all questions to:
  1317. X
  1318. X    rcs-bugs@cs.purdue.edu
  1319. X
  1320. X*/
  1321. X
  1322. X
  1323. X
  1324. X/* $Log: rcskeys.c,v $
  1325. X * Revision 5.0  1990/08/22  08:12:54  eggert
  1326. X * Add -k.  Ansify and Posixate.
  1327. X *
  1328. X * Revision 4.3  89/05/01  15:13:02  narten
  1329. X * changed copyright header to reflect current distribution rules
  1330. X * 
  1331. X * Revision 4.2  87/10/18  10:36:33  narten
  1332. X * Updating version numbers. Changes relative to 1.1 actuallyt
  1333. X * relative to 4.1
  1334. X * 
  1335. X * Revision 1.2  87/09/24  14:00:10  narten
  1336. X * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  1337. X * warnings)
  1338. X * 
  1339. X * Revision 4.1  83/05/04  10:06:53  wft
  1340. X * Initial revision.
  1341. X * 
  1342. X */
  1343. X
  1344. X
  1345. X#include "rcsbase.h"
  1346. X
  1347. XlibId(keysId, "$Id: rcskeys.c,v 5.0 1990/08/22 08:12:54 eggert Exp $")
  1348. X
  1349. X
  1350. Xconst char *const Keyword[] = {
  1351. X    /* This must be in the same order as rcsbase.h's enum markers type. */
  1352. X    nil,
  1353. X    AUTHOR, DATE, HEADER, IDH,
  1354. X    LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE,
  1355. X};
  1356. X
  1357. X
  1358. X
  1359. X    enum markers
  1360. Xtrymatch(string)
  1361. X    const char *string;
  1362. X/* function: Checks whether string starts with a keyword followed
  1363. X * by a KDELIM or a VDELIM.
  1364. X * If successful, returns the appropriate marker, otherwise Nomatch.
  1365. X */
  1366. X{
  1367. X        register int j;
  1368. X    register const char *p, *s;
  1369. X    for (j = sizeof(Keyword)/sizeof(*Keyword);  (--j);  ) {
  1370. X        /* try next keyword */
  1371. X        p = Keyword[j];
  1372. X        s = string;
  1373. X        while (*p++ == *s++) {
  1374. X            if (!*p)
  1375. X                switch (*s) {
  1376. X                case KDELIM:
  1377. X                case VDELIM:
  1378. X                    return (enum markers)j;
  1379. X                default:
  1380. X                    return Nomatch;
  1381. X                }
  1382. X        }
  1383. X        }
  1384. X        return(Nomatch);
  1385. X}
  1386. X
  1387. END_OF_FILE
  1388.   if test 2404 -ne `wc -c <'src/rcskeys.c'`; then
  1389.     echo shar: \"'src/rcskeys.c'\" unpacked with wrong size!
  1390.   fi
  1391.   # end of 'src/rcskeys.c'
  1392. fi
  1393. echo shar: End of archive 2 \(of 12\).
  1394. cp /dev/null ark2isdone
  1395. MISSING=""
  1396. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1397.     if test ! -f ark${I}isdone ; then
  1398.     MISSING="${MISSING} ${I}"
  1399.     fi
  1400. done
  1401. if test "${MISSING}" = "" ; then
  1402.     echo You have unpacked all 12 archives.
  1403.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1404. else
  1405.     echo You still must unpack the following archives:
  1406.     echo "        " ${MISSING}
  1407. fi
  1408. exit 0
  1409. exit 0 # Just in case...
  1410.